-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
chore(test): use t.mock.module for mocking
#7660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR cleans up the test harness by removing the unused mocks for next-router and next-intl and switching to using node:test's built-in mocking via t.module.mock. The changes include removing legacy mock files and loader modifications, and introducing a new setup.jsx file that sets up mocks for next-intl and next-intl/navigation.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apps/site/tests/setup.mjs | Removed the legacy setup that registered a custom module loader. |
| apps/site/tests/setup.jsx | Added new mocking setup using node:test's t.module.mock for next-intl and its navigation. |
| apps/site/tests/mocks/next-router.mjs | Removed the unused next-router mock. |
| apps/site/tests/mocks/next-intl.jsx | Removed the legacy next-intl mock file. |
| apps/site/tests/loader.mjs | Removed the custom module resolution hook, now unnecessary with t.module.mock. |
Files not reviewed (1)
- apps/site/package.json: Language not supported
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #7660 +/- ##
==========================================
+ Coverage 74.54% 74.61% +0.06%
==========================================
Files 96 96
Lines 7673 7685 +12
Branches 194 192 -2
==========================================
+ Hits 5720 5734 +14
+ Misses 1951 1949 -2
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
t.module.mock for mockingt.mock.module for mocking
|
Feel free to fast-track this. Giving a 👍 |
|
Lighthouse Results
|
Description
I kept wondering why, whenever I attempted to mock these modules with
node:testmocking, I would always get an error that they weren't defined. Then it hit me:next-routerisn't defined, because we don't use it 🤦.So, this PR removes the mock for next-router, and uses
node:testfor mockingnext-intl.Validation
All tests should pass
Related Issues
Ref: https://github.com/nodejs/nodejs.org/pull/7623/files#r2032206240
Check List
npm run formatto ensure the code follows the style guide.npm run testto check if all tests are passing.npx turbo buildto check if the website builds without errors.